<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>

  let url = "http://10.11.50.46:3000/getgoods";

  async function fn(){
    console.log(1)
    const res = await ajax(url);
    console.log(2)
    // console.log(res);
    console.log(3)
  }
  fn();



  
  function ajax(url, data={}){
    let str = "";
    for(let i in data){
      str += `${i}=${data[i]}&`
    }
    url += "?" + str.slice(0,-1);

    const xhr = new XMLHttpRequest();
    xhr.open("get", url);
    xhr.send();
    return new Promise((resolve, reject)=>{
      xhr.onload = function(){
        if(xhr.status === 200){
          resolve(xhr.responseText);
        }else{
          reject(xhr.status);
        }
      }
    })
  }

</script>
</html>